package tests

import (
	"math"
)

func calcTriangle(a, b int) int {
	var c int
	c = int(math.Sqrt(float64(a*a + b*b)))
	return c
}

func FindLongString(s string) int {
	//find := ""
	lastOccurred := make(map[rune]int)
	//优化技巧，用空间换时间
	//lastOccurred := make([]int, 0xffff)
	//lastOccurred[0x65] = 1
	//lastOccurred[0x8BFe] = 6
	start := 0
	maxLength := 0
	//遍历字符串
	for i, ch := range []rune(s) {
		if lastI, ok := lastOccurred[ch]; ok && lastI >= start {
			start = lastOccurred[ch] + 1
		}
		if i-start+1 > maxLength {
			maxLength = i - start + 1
		}
		//更新字符最后一次出现的位置
		lastOccurred[ch] = i
	}
	return maxLength
}
